package day4;

public class Test04 {
    public static void main(String[] args) {
        //输出表头部分
        System.out.println("----------------------商场库存清单----------------------");
        System.out.printf("%-13s %-6s %-8s %s%n", "品牌型号", "尺寸", "价格", "库存数");


        //定义变量并输出表格内容
        String[] model={"MacBookAir", "ThinkPadT490", "MateBook 14"};//品牌型号
        double[] size={13.3, 14.0, 14.0};//尺寸
        double[] price={5699.0, 8499.0, 7199.0};//价格
        int[] count={5, 10, 18};//库存数
        for (int i = 0; i < model.length; i++) {
            System.out.printf("%-17s %-8.1f %-9.1f %d%n",model[i],size[i],price[i],count[i]);

        }

        //计算并输出表格尾巴
        //1.计算总库存数
        int total =0;
        for (int i = 0; i < size.length; i++) {
            total+=count[i];
        }
        //2.计算商品库存总金额
        double sum = 0;
        for (int i = 0; i < size.length; i++) {
            sum+=(count[i]*price[i]);
        }
        //3.输出
        System.out.println("------------------------------------------------------");
        System.out.println("总库存数："+total);
        System.out.println("商品库存总金额:"+sum);
    }
}
